// @author A0096579E

package rightnow.util;

import java.util.Comparator;

import rightnow.storage.Task;

/**
 * PinnedComparator imposes ordering of Task based on their isPinned attribute.
 * A Task that is pinned comes before one that is not.
 */
public class PinnedComparator implements Comparator<Task> {
	
	@Override
	public int compare(Task taskA, Task taskB) {
		if (taskA.isPinned() && !taskB.isPinned()) {
			return -1;
		} else if (!taskA.isPinned() && taskB.isPinned()) {
			return 1;
		} else { // if both tasks are pinned or unpinned
			return 0;
		}
	}

}
